package com.xiaoyao.novel.listen;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;

import com.xiaoyao.novel.service.ClickService;
import com.xiaoyao.novel.task.BookCrawlTask;

public class NovelListener implements ServletContextListener {
	static Logger logger = Logger.getLogger(NovelListener.class);

	public void contextInitialized(ServletContextEvent sce) { 
////		启动 dede cms 的爬取
//		logger.warn("启动dedecms 的爬虫.");
//		NovelCrawl novelCrawl = new NovelCrawl();
//		novelCrawl.startTask();
//		 启动爬取线程
		logger.warn("启动爬取线程.");
		BookCrawlTask task = new BookCrawlTask();
		task.startTask();
		
	}

	public void contextDestroyed(ServletContextEvent arg0) {
		ClickService.save();
	}

}
